package com.ming_za.odupdaterserver.core.mco_core.Cmd.BasisCmd;

import com.ming_za.odupdaterserver.core.mco_core.API.CmdOperate;
import com.ming_za.odupdaterserver.core.mco_core.Cmd.CmdCreate;
import com.ming_za.odupdaterserver.core.mco_core.Cmd.CmdData;
import com.ming_za.odupdaterserver.core.mco_core.Cmd.CmdManager;
import com.ming_za.odupdaterserver.core.utils.Msg;

import java.util.Map;

@CmdCreate(cmd = "help",explain = "查看指令帮助")
public class HelpCmd implements CmdOperate {

    private final Msg msg;

    public HelpCmd(Msg msg) {
        this.msg = msg;
    }

    @Override
    public boolean onCommand(String command, String[] args) {

        msg.soutMsg("&b&l=========指令帮助==========");

        Map<String, CmdData> cmdList = CmdManager.getInstance().getCmdList();

        for (String key: cmdList.keySet()){
            CmdData cd = cmdList.get(key);
            if (cd.isHide()){
                continue;
            }
            String exp = cd.getExplain();
            msg.soutMsg("&6&l" + key + exp);
        }

        msg.soutMsg("&b&l=========================");

        return true;
    }
}
